package com.ruoyi.configuration.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.configuration.mapper.MgTeamSigningRewardsMapper;
import com.ruoyi.configuration.domain.MgTeamSigningRewards;
import com.ruoyi.configuration.service.IMgTeamSigningRewardsService;

/**
 * 团队签约奖励Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-16
 */
@Service
public class MgTeamSigningRewardsServiceImpl implements IMgTeamSigningRewardsService 
{
    @Autowired
    private MgTeamSigningRewardsMapper mgTeamSigningRewardsMapper;

    private RedisTemplate redisTemplate;
    
    @Autowired
    public void setRedisTemplate(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
    
    /**
     * 查询团队签约奖励
     * 
     * @param id 团队签约奖励主键
     * @return 团队签约奖励
     */
    @Override
    public MgTeamSigningRewards selectMgTeamSigningRewardsById(String id)
    {
        return mgTeamSigningRewardsMapper.selectMgTeamSigningRewardsById(id);
    }

    /**
     * 查询团队签约奖励列表
     * 
     * @param mgTeamSigningRewards 团队签约奖励
     * @return 团队签约奖励
     */
    @Override
    public List<MgTeamSigningRewards> selectMgTeamSigningRewardsList(MgTeamSigningRewards mgTeamSigningRewards)
    {
        return mgTeamSigningRewardsMapper.selectMgTeamSigningRewardsList(mgTeamSigningRewards);
    }

    /**
     * 新增团队签约奖励
     * 
     * @param mgTeamSigningRewards 团队签约奖励
     * @return 结果
     */
    @Override
    public int insertMgTeamSigningRewards(MgTeamSigningRewards mgTeamSigningRewards)
    {
        mgTeamSigningRewards.setCreateTime(DateUtils.getNowDate());
        mgTeamSigningRewards.setUpdateTime(DateUtils.getNowDate());
        
        redisTemplate.delete("team-sign-manager:");
        
        return mgTeamSigningRewardsMapper.insertMgTeamSigningRewards(mgTeamSigningRewards);
    }

    /**
     * 修改团队签约奖励
     * 
     * @param mgTeamSigningRewards 团队签约奖励
     * @return 结果
     */
    @Override
    public int updateMgTeamSigningRewards(MgTeamSigningRewards mgTeamSigningRewards)
    {
        mgTeamSigningRewards.setUpdateTime(DateUtils.getNowDate());
        
//        mgTeamSigningRewards.setDiscount(mgTeamSigningRewards.getDiscount().multiply(new BigDecimal(10)));
        
        redisTemplate.delete("team-sign-manager:");
        
        return mgTeamSigningRewardsMapper.updateMgTeamSigningRewards(mgTeamSigningRewards);
    }

    /**
     * 批量删除团队签约奖励
     * 
     * @param ids 需要删除的团队签约奖励主键
     * @return 结果
     */
    @Override
    public int deleteMgTeamSigningRewardsByIds(String[] ids)
    {
        return mgTeamSigningRewardsMapper.deleteMgTeamSigningRewardsByIds(ids);
    }

    /**
     * 删除团队签约奖励信息
     * 
     * @param id 团队签约奖励主键
     * @return 结果
     */
    @Override
    public int deleteMgTeamSigningRewardsById(String id)
    {
    	 redisTemplate.delete("team-sign-manager:");
        return mgTeamSigningRewardsMapper.deleteMgTeamSigningRewardsById(id);
    }

	@Override
	public <VO> int updatePayStatus(VO payManager) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<MgTeamSigningRewards> selectListById(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<MgTeamSigningRewards> selectListByIds(int[] ids) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <VO> List<VO> getOrderLogVOSById(int id, Class<VO> voClass) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <VO> int batchInsert(List<VO> data) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int batchInsert(List<MgTeamSigningRewards> data, int id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public MgTeamSigningRewards selectById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<MgTeamSigningRewards> selectList(MgTeamSigningRewards manuscript) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int insert(MgTeamSigningRewards manuscript) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int update(MgTeamSigningRewards manuscript) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByIds(Integer[] ids) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteById(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public long maxId() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public long minId() {
		// TODO Auto-generated method stub
		return 0;
	}
}
